using System;
using bitzhuwei.Compiler;

namespace bitzhuwei.GLSLFormat {
    /// <summary>
    /// Correspond to the Vn node jump_statement in the grammar(GLSL).
    /// </summary>
    internal partial class Vnjump_statement : IFullFormat {
        // [342] jump_statement = 'continue' ';' ;
        // [343] jump_statement = 'break' ';' ;
        // [344] jump_statement = 'return' ';' ;
        // [345] jump_statement = 'return' expression ';' ;
        // [346] jump_statement = 'discard' ';' ;


        private readonly IFullFormat complex;

        private readonly TokenRange _scope;
        public TokenRange Scope => _scope;
        public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
            context.PrintBlanksAnd(this.complex, preConfig, writer);
        }


        // [342] jump_statement = 'continue' ';' ;
        public Vnjump_statement(Token r1, Token r0) {
            this.complex = new complex0(r1, r0);
            this._scope = new TokenRange(r1, r0);
        }
        class complex0 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r1, preConfig, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Token r1;
            public readonly Token r0;
            public complex0(Token r1, Token r0) {
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r1, r0);
            }
        }

        // [343] jump_statement = 'break' ';' ;
        // complex1 repeated with complex0

        // [344] jump_statement = 'return' ';' ;
        // complex2 repeated with complex0

        // [345] jump_statement = 'return' expression ';' ;
        public Vnjump_statement(Token r2, Vnexpression r1, Token r0) {
            this.complex = new complex3(r2, r1, r0);
            this._scope = new TokenRange(r2, r0);
        }
        class complex3 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r2, preConfig, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Token r2;
            public readonly Vnexpression r1;
            public readonly Token r0;
            public complex3(Token r2, Vnexpression r1, Token r0) {
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r2, r0);
            }
        }

        // [346] jump_statement = 'discard' ';' ;
        // complex4 repeated with complex0



    }
}
